package net.wofly.sale.order.util;

import net.wofly.common.util.Identities;
import net.wofly.sale.order.domain.Order;
import net.wofly.sale.stock.domain.InOutStockDetail;

import java.util.List;

public class OrderUtil {
    
    public static void buildInOutStockDetail(
            Long modifyDate, List<InOutStockDetail> inOutStockDetails, String commodityTerminalID, Integer num) {
        buildInOutStockDetailsObject(modifyDate, inOutStockDetails, commodityTerminalID, num);
    }
    
    public static void buildInOutStockDetailsObject(
            Long modifyDate, List<InOutStockDetail> inOutStockDetails, String commodityTerminalID, Integer num) {
        InOutStockDetail inOutStockDetail = new InOutStockDetail();
        inOutStockDetail.setInOutStockDetailID(Identities.uuid2());
        inOutStockDetail.setCommodityTerminalID(commodityTerminalID);
        inOutStockDetail.setNum(num);
        inOutStockDetail.setModifyDate(modifyDate);
        inOutStockDetails.add(inOutStockDetail);
    }
    
    /**
     * 在线支付扫码支付的方式 （只有会员订单、流通订单、酒店订单的自助下单方式，客户自助支付，自己本地app支付）
     *
     * @param order
     * @param payFlag
     * @return
     */
    public static Integer getOnlinePayCurrStatus4Workflow(Order order, boolean payFlag) {
        Integer orderType = order.getOrderType();
        if (OrderType.会员订单.getValue().intValue() == orderType || OrderType.流通订单.getValue().intValue() == orderType ||
                OrderType.酒店订单.getValue().intValue() ==
                        orderType) {
            if (payFlag) {
                //订单己支付
                return OrderStatus.订单己支付.getValue();
            } else {
                //货到付款
                return OrderStatus.货到付款_未支付.getValue();
            }
        }
        return null;
    }
    
    
}
